//
// Created by LONG on 2020/10/19.
//

#ifndef O5G_SRC_O5GUE_L2_INCLUDE_L2DEF_H_
#define O5G_SRC_O5GUE_L2_INCLUDE_L2DEF_H_

#include "../../../../lib/csp/include/cspApi.h"
#include "../../include/ueApi.h"
#include "../../lcore/include/commDef.h"

typedef struct UeL2UeInst
{
    uint32_t inUse;
    uint32_t ueId;

    uint32_t ueIdx;

    uint16_t slotNum;
    S_O5gSfnSlot currAirSfnSlot;
    S_O5gSfnSlot schSfnSlot;

    S_VarRingBuffer *pL2L1CpMsgQue;
    S_VarRingBuffer *pL1L2CpMsgQue;
    S_VarRingBuffer *pL2L1UpMsgQue;
    S_VarRingBuffer *pL1L2UpMsgQue;

    S_OsSelect ttiIntSelector;

} S_UeL2UeInst;

typedef struct UeL2Context
{
    E_AppType appType;
    E_AppState appState;

    pthread_t ulTid;
    pthread_t dlTid;

    S_OsSelect ulTtiSelector;
    S_OsSelect dlTtiSelector;

    S_Poller *ulPoller;
    S_Poller *dlPoller;

    S_VarRingBuffer *pL3iL1iMsgQue;
    S_VarRingBuffer *pL1iL3iMsgQue;

    uint32_t ueInstNum;
    S_UeL2UeInst ueInst[UE_UE_INST_NUM_MAX];
    char sockRecvBuffer[SOCK_BUFFER_SIZE];
} S_UeL2Context;

extern S_UeL2Context *gpUeL2Context;

#endif //O5G_SRC_O5GUE_L2_INCLUDE_L2DEF_H_
